package com.tansun.easycare.ruleSceneManage.action;
import com.tansun.easycare.ruleSceneManage.service.IRuleSceneManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

import com.jeedev.msdp.base.web.BaseAction;
import com.jeedev.msdp.base.web.ResponseVO;

import java.util.Map;


@RestController
@RequestMapping("/ruleSceneManage")
@Api(tags = "ruleSceneManage")
@Slf4j
public class RuleSceneManageAction extends BaseAction {

    @Autowired
    private IRuleSceneManageService ruleSceneManageService;


    /**
    * @功能描述:分页查询
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/findRuleSceneManagePage",method = RequestMethod.POST)
    @ApiOperation(value = "分页查询")
    public ResponseVO findRuleSceneManagePage(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
        return ruleSceneManageService.findPage(params);
    }
    /**
    * @功能描述:新增或修改一条记录
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
    @ApiOperation(value = "新增或修改一条记录")
    public ResponseVO insertOrUpdate(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
    if(params == null) {
        return this.createResponse(null, ResponseVO.ERROR, "参数不能为空!");
    }
        String id = (String)params.get("id");
        if(null == id || "".equals(id)) {
        return ruleSceneManageService.insert(params);
    }else {
        return ruleSceneManageService.updateById(params);
    }
}


    /**
    * @功能描述:根据主键ID删除一条记录
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/deleteRuleSceneManageById", method = RequestMethod.POST)
    @ApiOperation(value = "根据主键ID删除一条记录")
    public ResponseVO deleteRuleSceneManageById(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
        return ruleSceneManageService.deleteById(params);
    }

    /**
    * @功能描述:根据主键ID查询一条记录
    * @param params
    * @return
    * @作者
    * @创建时间 2021-02-20
    */
    @RequestMapping(value = "/selectRuleSceneManageById", method = RequestMethod.POST)
    @ApiOperation(value = "根据主键ID查询一条记录")
    public ResponseVO selectRuleSceneManageById(@ApiParam(value = "请求参数", required = true) @RequestBody Map<String, Object> params) {
        return ruleSceneManageService.selectById(params);
    }

}
